package ie.timalb.chess.main.core.grid;

public class GridDefaultIterationStrategy implements CellIteratorStrategy {
	Cell firstCell;
	Cell lastCell;

	public GridDefaultIterationStrategy(Cell firstCell, Cell lastCell) {
		setFirstCell(firstCell);
		setLastCell(lastCell);
	}

	@Override
	public Cell getFirstCell() {
		return firstCell;
	}

	@Override
	public Cell getLastCell() {
		return lastCell;
	}

	@Override
	public Cell getNextCell(Cell currentCell) {
		CellLocation nextLocation = new CellLocation(
														currentCell.getLocation().getCoordinateX() + 1,
														currentCell.getLocation().getCoordinateY()
													);
		return currentCell.getParent().getCell (nextLocation);
	}

	@Override
	public Cell onNextOutOfRange(Cell currentCell) {
		// TODO Auto-generated method stub
		return null;
	}

	private void setFirstCell(Cell firstCell) {
		this.firstCell = firstCell;
	}

	private void setLastCell(Cell lastCell) {
		this.lastCell = lastCell;
	}



}
